##
# MainUtils.py
#
# Description: A file containing many usefull utilities for main
##
import libtcodpy as libtcod
import time
from Constants import *
from Menu import *

##
# initializeBasicGUI()
#
# Description: Loads the tile-set, initializes the window and limits the FPS
#
# Returns: the current mouse and key values
##
def initializeBasicGUI():
    # Include a custom tileset
    libtcod.console_set_custom_font('arial10x10.png', libtcod.FONT_TYPE_GREYSCALE | libtcod.FONT_LAYOUT_TCOD)

    # Initialize the window  (width,        height,         title,              isFullscreen)
    libtcod.console_init_root(SCREEN_WIDTH, SCREEN_HEIGHT, 'Eldritch Dungeons', False)

    # Limit the frames per second for a real-time game
    libtcod.sys_set_fps(LIMIT_FPS)

##
# initalizeMainMenuGUI()
#
# Description: Initializes the main menu
#
# Returns: the main Menu (Menu)
##
def initializeMainMenuGUI():
    # Initialize the Menu GUI
    options = ['New Game', 'Load Game', 'Help']
    menu = Menu(TITLE, options, SCREEN_WIDTH)
    return menu

##
# initalizeNewGameMenuGUI()
#
# Description: Initializes the new Game menu
#
# Returns: the new Game Menu (Menu)
##
def initializeNewGameMenuGUI():
    # Initialize the Menu GUI
    options = ['Create Map', 'Main Menu']
    menu = Menu('New Game', options, SCREEN_WIDTH)
    return menu

##
# initializeLoadGameMenuGUI()
#
# Description: Initializes the load game menu
#
# Returns the load game menu (Menu)
##
def initializeLoadGameMenuGUI():
    # Initialize the Menu GUI
    options = ['Save 1', 'Main Menu']
    menu = Menu('Load Game', options, SCREEN_WIDTH)
    return menu

##
# initializeHelpMenuGUI()
#
# Description: Initializes the help menu
#
# Returns the help menu (Menu)
##
def initializeHelpMenuGUI():
    # Initialize the Menu GUI
    options = ['Nothing here for now', 'Main Menu']
    menu = Menu('Help', options, SCREEN_WIDTH)
    return menu

##
# startMenuSelection()
#
# Description: starts the menu selection process at the start of the game
##
def startMenuSelection():
    # The first menu to call
    currMenu = 'Main Menu'
    # Initialize the windows
    main = initializeMainMenuGUI()
    new = initializeNewGameMenuGUI()
    load = initializeLoadGameMenuGUI()
    help = initializeHelpMenuGUI()

    # Start the menu selection process
    while not libtcod.console_is_window_closed():
        # open the next menu
        if currMenu == 'Main Menu':
            nextMenu = main.displayMenu()
        elif currMenu == 'New Game':
            nextMenu = new.displayMenu()
        elif currMenu == 'Load Game':
            nextMenu = load.displayMenu()
        elif currMenu == 'Help':
            nextMenu = help.displayMenu()
        elif currMenu == 'Create Map':
            #createMap()
            print "Creating Map"
            break
        elif currMenu == 'Save 1':
            #load(Save 1)
            print 'Loading Save 1'
            break
        else:
           break
        if nextMenu != None:
            time.sleep(.2)
            currMenu = nextMenu





